package com.candy.niuniu.message;

import com.candy.niuniu.logapidubbo.LogService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author suYanLong
 * @version 1.0
 * @date 2023/10/9 16:49
 * @Description 描述
 */
@Component
public class StarterTask implements CommandLineRunner {

    // check = false 启动不检查服务提供者
    @DubboReference(check = false)
    LogService logService;

    @Override
    public void run(String... args) throws Exception {

        for (int i = 0; i < 100; i++) {
            RpcContext.getClientAttachment().setAttachment("server", "message");
            logService.saveLog("message log save");
            String result = RpcContext.getServerContext().getAttachment("result");
            System.out.println(result);
        }
    }

}
